package character;

import Sorts.Books;
import java.util.ArrayList;
import java.util.List;

public class Users {
    private final List<Books> myBooks = new ArrayList<>();
    private boolean isBlack ;
    private String userName;
    private String password;

    public Users(String userName,String password) {
        this.userName = userName;
        this.password = password;
        this.isBlack = false;
    }

    public boolean isBlack() {
        return isBlack;
    }
    public void setBlack() {
        isBlack = true;
    }

    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsername() {
        return userName;
    }
    public void setUsername(String username) {
        this.userName = username;
    }

    public List<Books> getMyBooks()
    {
        return myBooks;
    }
//找一种书
    public List<Books> getA_kindofBook (int sort) {
        List<Books> fenlei_books = new ArrayList<>();

        for (Books wodeBook : myBooks) {
            if (wodeBook.getSort() == sort) {
                fenlei_books.add(wodeBook);
            }
        }
        return fenlei_books;
    }
//借书
    public void borrowBook(Books book) {
        myBooks.add(book);
    }
//还书
    public void returnBook(Books book) {
        myBooks.remove(book);
    }
//还所有书
    public void returnAll() {
        myBooks.clear();
    }

}
